<template>
    <div id="print-html" ref="PrintView">
      <table style="height: 358px; width: 95%; margin-left: auto; margin-right: auto;border-collapse: collapse;" border="1px" cellpadding="0" cellspacing="0" bordercolor ="#000000"  bordercolordark ="#000000">
        <!-- <caption style="padding: 13px 0; font-size: 22px; font-weight: inherit;">请假条</caption> -->
        <tbody v-if="taskType =='1'">
          <tr style="">
            <!-- <th style="text-align: center; vertical-align: middle;">任务类型</th> -->
            <th style="text-align: center; vertical-align: middle;word-wrap:break-word;" colspan="7">{{infoForm&&infoForm.room?infoForm.room:''}}</th>
          </tr>
          <tr style="">
            <th style="text-align: center; vertical-align: middle;">姓名</th>
            <td style="text-align: center; vertical-align: middle;word-wrap:break-word;" colspan="7">{{infoForm&&infoForm.patientName?infoForm.patientName:''}}</td>
          </tr>
          <tr style="">
            <th style="text-align: center; vertical-align: middle;">术间</th>
            <td style="text-align: center; vertical-align: middle;word-wrap:break-word;" colspan="7">{{infoForm&&infoForm.room?infoForm.room:''}}</td>
          </tr>
          <tr style="">
            <th style="text-align: center; vertical-align: middle;">手术日期</th>
            <td style="text-align: center; vertical-align: middle;word-wrap:break-word;" colspan="7">{{infoForm&&infoForm.operationTime?infoForm.operationTime:''}}</td>
          </tr>
          <tr style="">
            <th style="text-align: center; vertical-align: middle;">出发地</th>
            <td style="text-align: center; vertical-align: middle;word-wrap:break-word;" colspan="7">{{infoForm&&infoForm.departure?infoForm.departure:''}}</td>
          </tr>
          <tr style="">
            <th style="text-align: center; vertical-align: middle;">目的地</th>
            <td style="text-align: center; vertical-align: middle;word-wrap:break-word;" colspan="7">{{infoForm&&infoForm.destination?infoForm.destination:''}}</td>
          </tr>
          <tr style="">
            <th style="text-align: center; vertical-align: middle;">任务创建时间</th>
            <td style="text-align: center; vertical-align: middle;word-wrap:break-word;" colspan="7">{{infoForm&&infoForm.createdAt?infoForm.createdAt:''}}</td>
          </tr>
          <tr >
            <th style="text-align: center; vertical-align: middle;">备注</th>
            <td style="text-align: center; vertical-align: middle;word-wrap:break-word;" colspan="7">{{infoForm&&infoForm.remind?infoForm.remind:''}}</td>
          </tr>
        </tbody>
        <tbody v-if="taskType =='2'">
          <tr style="">
            <th style="text-align: center; vertical-align: middle;">任务类型</th>
            <td style="text-align: center; vertical-align: middle;word-wrap:break-word;" colspan="7">{{infoForm&&infoForm.tBaseTaskTypeName?infoForm.tBaseTaskTypeName:''}}</td>
          </tr>
          <tr style="">
            <th style="text-align: center; vertical-align: middle;">姓名</th>
            <td style="text-align: center; vertical-align: middle;word-wrap:break-word;" colspan="7">{{infoForm&&infoForm.patientName?infoForm.patientName:''}}</td>
          </tr>
          <tr style="">
            <th style="text-align: center; vertical-align: middle;">病案/登记号</th>
            <td style="text-align: center; vertical-align: middle;word-wrap:break-word;" colspan="7">{{infoForm&&infoForm.caseRegNo?infoForm.caseRegNo:''}}</td>
          </tr>
          <tr style="">
            <th style="text-align: center; vertical-align: middle;">手术日期</th>
            <td style="text-align: center; vertical-align: middle;word-wrap:break-word;" colspan="7">{{infoForm&&infoForm.operationTime?infoForm.operationTime:''}}</td>
          </tr>
          <tr style="">
            <th style="text-align: center; vertical-align: middle;">患者地点</th>
            <td style="text-align: center; vertical-align: middle;word-wrap:break-word;" colspan="7">{{infoForm&&infoForm.departure?infoForm.departure:''}}</td>
          </tr>
          <tr style="">
            <th style="text-align: center; vertical-align: middle;">目的地</th>
            <td style="text-align: center; vertical-align: middle;word-wrap:break-word;" colspan="7">{{infoForm&&infoForm.destination?infoForm.destination:''}}</td>
          </tr>
          <tr style="">
            <th style="text-align: center; vertical-align: middle;">任务时间</th>
            <td style="text-align: center; vertical-align: middle;word-wrap:break-word;" colspan="7">{{infoForm&&infoForm.createdAt?infoForm.createdAt:''}}</td>
          </tr>
          <tr >
            <th style="text-align: center; vertical-align: middle;">备注</th>
            <td style="text-align: center; vertical-align: middle;word-wrap:break-word;" colspan="7">{{infoForm&&infoForm.remind?infoForm.remind:''}}</td>
          </tr>
        </tbody>
      </table>
    </div>
  </template>
  <script>
  // import moment from "moment"; // 日期格式化工具
  import {mapState} from "vuex";
   
  export default {
    name: 'PrintView',
    props: {
      //父组件传递 姓名字段
      name: {
        type: String,
        default: ''
      },
      //父组件传递 部门字段
      deptName: {
        type: String,
        default: ''
      },
      //父组件传递 时长字段
      duration: {
        type: String,
        default: ''
      },
      //根据工作站显示模板 1：护工工作站打印
      taskType: {
        type: String,
        default: '1'
      },
      //父组件传递对象参数
      infoForm: {
        type: Object,
        default () {
          return {}
        }
      },
    },
    data() {
      return {
        momentObj: null,
        checkUserIds:null,
        copyUserIds:null
      }
    },
    created() {
      // this.momentObj=moment
      console.log(this.infoForm)
    },
    watch: {},
    computed: {
      ...mapState(['userInfo']), // 获取用户数据
    },
      /**以下所有方法采用同步调用，防止打印时数据丢失**/
    methods: {
      /** 数据进行封装，页面进行回显 **/
      async getCheckUser(checkUserId,copyUserId){
        this.checkUserIds=await this.filterCheckedusers(checkUserId);
        this.copyUserIds= await this.filterCheckedusers(copyUserId);
      },
      /* 审批人 刷选 暴力方法，没做去重直接是清空在复制*/
      async filterCheckedusers(checkedIds) {
        checkedIds = checkedIds ? checkedIds.split(',') : []
        const checkedusers = []
        if(Array.isArray(checkedIds)) {
          checkedIds.forEach(item => {
            checkedusers.push(this.allUserlist.filter(i => (Boolean(item) && i.id === item))[0] )
          })
        } else if(checkedIds) {
          checkedusers.push(this.allUserlist.filter(i => i.id === checkedIds)[0])
        }
        return checkedusers.filter(item => item !== undefined)
      },
    },
  }
  </script>
   